﻿using System;

namespace NetSync.Core
{
    public class DispatchEventArgs : EventArgs
    {
        public DispatchEventArgs(string topic, ReadOnlyMemory<byte> message, INetConnection netConnection, bool isHandled = false)
        {
            Topic = topic;
            Message = message;
            NetConnection = netConnection;
            IsHandled = isHandled;
        }

        public INetConnection NetConnection { get; }

        public ReadOnlyMemory<byte> Message { get; }

        public string Topic {  get; }

        /// <summary>
        /// 数据是否被处理
        /// </summary>
        public bool IsHandled { get; set; }
    }

    public class DispatchErrorEventArgs : EventArgs
    {
        public DispatchErrorEventArgs(string topic, ReadOnlyMemory<byte> message, INetConnection netConnection, Exception exception, bool isHandled = false)
        {
            Topic = topic;
            Message = message;
            NetConnection = netConnection;
            Exception = exception;
            IsHandled = isHandled;
        }
        public INetConnection NetConnection { get; }

        public ReadOnlyMemory<byte> Message { get; }

        public string Topic { get; }

        public Exception Exception { get; }

        /// <summary>
        /// 数据是否被处理
        /// </summary>
        public bool IsHandled { get; set; }
    }
}
